<template>
  <div class="findpassword">
    <van-nav-bar>
      <!-- 插槽#===v-slot -->
      <template #left>
        <div class="logo-box">
          <div class="logo">
            <img class="auto-img" :src="img" alt />
          </div>
          <div class="logo-text">Luckin Coffee</div>
        </div>
      </template>
      <template #right>
        <div class="guang" @click="goPage('Menu')">先逛一逛</div>
      </template>
    </van-nav-bar>
    <div class="user-box">
      <div>
        <div class="welcome-zhtitle">找回密码</div>
        <div class="welcome-entitle">Find password!</div>
      </div>
      <div class="form-box">
        <van-form @submit="checkValidCode(sms)">
          <van-field
            v-model="email"
            name="email"
            label="邮箱号"
            placeholder="邮箱号"
            autocomplete="off"
            :rules="[
              { required: true, message: '请填写邮箱号' },
              { pattern: phoneReg, message: '邮箱号不正确' },
            ]"
          />
          <van-field
            v-model="sms"
            center
            clearable
            label="验证码"
            placeholder="请输入验证码"
          >
            <template #button>
              <van-button size="small" type="primary" @click="emailValidCode(email)">发送验证码</van-button>
            </template>
          </van-field>
          <div class="forgot-box">
            <div class="forgot-text" @click="goPage('Login')">已有账号,立即登录</div>
          </div>
          <div class="login-btn" style="margin: 16px">
            <van-button round block type="info" native-type="submit"
              >提&nbsp;&nbsp;&nbsp;交</van-button
            >
          </div>
          <div class="fan-btn" style="margin: 16px">
            <van-button
              round
              block
              type="info"
              native-type="button"
              @click="goPage('Login')"
              >返&nbsp;&nbsp;&nbsp;回</van-button
            >
          </div>
        </van-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "FindPassword",
  data() {
    return {
      //验证码
      sms:'',
      email:'',
      //头像
      img: require("../assets/images/home_active.png"),
      //密码框样式
      isOpen: false,
      //验证邮箱
      phoneReg: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
      //验证码
      passwordReg: /^[1-9]$/,
      userInfo: {
        phone: "",
        password: "",
      },
    };
  },
  methods: {
    //跳转页面(先逛一逛)  已有账号,立即登录
    goPage(name) {
      this.$router.push({ name });
    },
    //切换密码框显示隐藏状态
    togglePasswordStatus() {
      this.isOpen = !this.isOpen;
    },
    //获取邮箱验证码接口
    emailValidCode(email) {
        this.axios({
            method: 'post',
            url: '/emailValidCode',
            data: {
                email
            }
        }).then(res=>{
            
        }).catch(err=>{
            
        })
    },
    //验证码验证接口
    checkValidCode(sms) {
        this.axios({
            method: 'post',
            url: '/checkValidCode',
            data: {
                validCode : sms
            }
        }).then(res=>{
            
        })
    }
    
  },
};
</script>

<style lang="less" scoped>
/deep/ .van-button--primary {
    background-color: #00BFFF;
    border:1px solid #1989FA;
}
.fan-btn {
    /deep/ .van-button--info{
        background-color: #fff;
        color:#000;
        border:1px solid #e6e6e6;
    }

}
.findpassword {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  .forgot-box {
    margin-top: 10px;
    display: flex;
  }
  .forgot-text {
    margin-left: auto;
    font-size: 14px;
    color: #666;
  }
  .login-btn {
    margin-top: 50px;
  }
  .form-box {
    margin-top: 50px;
  }
  .welcome-zhtitle {
    font-size: 22px;
    color: #555;
    font-weight: bold;
    margin-bottom: 20px;
  }
  .welcome-entitle {
    font-size: 16px;
    color: #888;
  }
  .user-box {
    margin-top: 80px;
    padding: 15px;
  }
  .guang {
    color: deepskyblue;
    font-size: 14px;
    font-weight: bold;
  }
  .logo-box {
    display: flex;
    align-items: center;
  }
  .logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
  }
  .logo-text {
    margin-left: 10px;
    font-size: 16px;
    font-weight: bold;
    color: #666;
  }
}
</style>